
#include "delay.h"
#include "utils.h"
#include "stdint.h"


unsigned int micros() {

	uint32_t cycle_l;

    csrr(cycle,cycle_l);//read_csr(cycle);

    return cycle_l/24;

}


void delay_ms(unsigned int ms)
{
	unsigned int start = micros();

	while (ms > 0) {

		while ( ms > 0 && (micros() - start) >= 1000) {
			ms--;
			start += 1000;
		}
	}
}